package com.example.zookeeperlock.example;

import org.I0Itec.zkclient.ZkClient;

import java.nio.file.Path;
import java.util.List;

/**
 * @Author: zhangrongqing
 * @Date: 2020/8/31 20:47
 */
public class ZkclientTest {

    //zk地址和端口
    public static final String ZK_ADDR = "127.0.0.1:2181";
    //超时时间
    public static final int SESSION_TIMEOUT = 10000;

    public static final String PATH = "/lock";
    //创建zk
    protected static ZkClient zkClient = new ZkClient(ZK_ADDR, SESSION_TIMEOUT);


    public static void main(String[] args) {
        zkClient.createPersistent(PATH);

        ZkclientTest.zkClient.createEphemeralSequential(PATH + "/", "test");

        ZkclientTest.zkClient.createEphemeralSequential(PATH + "/", "test");

        ZkclientTest.zkClient.createEphemeralSequential(PATH + "/", "test");

        List<String> children = zkClient.getChildren(PATH);

        System.out.println(children);
    }


}
